﻿package gamestates
{
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Georg Kamptner
	 */
	public class GameStateAddBody implements IGameState
	{
		private var _game:Game;
		
		public function GameStateAddBody(game:Game) 
		{
			_game = game;
		}
		
		public function init():void
		{
			_game.logStatus("AddBox - Mode");
		}
		
		public function onMouseUp(e:MouseEvent):void
		{
			if (_game.isPlayerAllowedToExecuteAction() && !_game.is_paused)
			{
				_game.addBodyToCurrentPlayer();
				_game.executeActionOnCurrentPlayer();
			}
		}
		
		public function changeStateToStartScreen():void
		{
			_game.resetGameWorld();
			_game.hideInGameView();
			_game.state = _game.getGameState(Game.START_SCREEN);
			_game.state.init();
		}
		
		public function changeStateToGameSelection():void
		{
			// no we don`t want that to happen.
		}
		public function changeStateToIntroScreen():void{}
		
		public function changeStateToDefault():void
		{
			// change to new state
			_game.state = _game.getGameState(Game.DEFAULT);
			_game.state.init();
		}
		
		public function changeStateToAddBody():void {}
		public  function changeStateToSettingsScreen():void{}
		public function changeStateToModifyBodies():void
		{
			// change to new state
			_game.state = _game.getGameState(Game.MODIFY_BODIES);
			_game.state.init();
		}
		
		public function swapPlayers():void
		{
			_game.swapPlayers();
		}
		
		public function quit():void 
		{
			_game.changeStateToStartScreen();
		}
		
		public function onPlayerWon(player:Player):void
		{
			changeStateToDefault();
			_game.onPlayerWon(player);
			
			_game.logStatus("PLAYER '" + player.name + "' WON!");
		}
	}
	
}